package userTests;

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;

public class WithdrawExistBankTests extends TestBaseUser {

	@Test
	public void testWithdraw() {
		openMainPageUser();
		gotoSignInUser();
		LoginLogoutDataUser signIn = new LoginLogoutDataUser();
		signIn.phoneNumber = "955413233";
		signIn.password = "!23Qwe";
		fillSignInUser(signIn);
		submitSignInUser();

		isAntiFishingImgPresent();
		pointCurrency();
		gotoWithdrawForm();
		fillWithdrawForm();
		gotoPreviewWithdraw();
		fillInvalidPayPassword();
		confirmWithdraw();
		isAlertErrorBlockPresent();
		fillValidPayPassword();
		confirmWithdraw();
		isAlertSuccessBlockPresent();
		
		logout();
		confirmMainPageUser();
	}

	private void confirmWithdraw() {
		wd.findElement(By.name("confirm")).click();
	}

	private void gotoPreviewWithdraw() {
		wd.findElement(By.name("preview")).click();
	}

	private void fillWithdrawForm() {
		new Select(wd.findElement(By.id("payment_details_id")))
				.selectByVisibleText("Euro-bank");
		wd.findElement(By.id("amount_integer")).clear();
		wd.findElement(By.id("amount_integer")).sendKeys("100");
		wd.findElement(By.id("comments")).clear();
		wd.findElement(By.id("comments")).sendKeys("zxcv");
	}

	private void gotoWithdrawForm() {
		wd.findElement(By.id("btnWithdraw")).click();
	}



}
